<div class="single-head">
	<h3 class="pull-left"><i class="fa fa-desktop purple"></i> <?php echo UserModule::t("Manage Users"); ?></h3>
	<div class="breads pull-right">
		<strong>Nav</strong> : <a href="<?php echo Yii::app()->createUrl('user'); ?>">Home</a>  / Manage
	</div>
	<div class="clearfix"></div>
</div>
<?php 
$this->beginWidget('zii.widgets.CPortlet', array(
	'htmlOptions'=>array(
		'class'=>''
	)
));
$this->widget('bootstrap.widgets.TbMenu', array(
	'type'=>'pills',
	'items'=>array(
		array('label'=>'Create', 'icon'=>'icon-plus', 'url'=>Yii::app()->controller->createUrl('create'), 'linkOptions'=>array()),
        array('label'=>'List', 'icon'=>'icon-th-list', 'url'=>Yii::app()->controller->createUrl('admin?activeMail='),'active'=>true, 'linkOptions'=>array()),
	),
));
$this->endWidget();
?>
<?php $this->widget('bootstrap.widgets.TbGridView', array(
	'id'=>'user-grid',
	'dataProvider'=>$model->search(),
	'type' => 'striped bordered',
	'filter'=>$model,
	'columns'=>array(
		array(
			'name' => 'id',
			'type'=>'raw',
			'value' => 'CHtml::link(CHtml::encode($data->id),array("admin/update","id"=>$data->id))',
		),
		array(
			'name' => 'username',
			'type'=>'raw',
			'value' => 'CHtml::link(UHtml::markSearch($data,"username"),array("admin/view","id"=>$data->id))',
		),
		array(
			'name'=>'email',
			'type'=>'raw',
			'value'=>'CHtml::link(UHtml::markSearch($data,"email"), "mailto:".$data->email)',
		),
		'create_at',
		'lastvisit_at',
		array(
			'name'=>'superuser',
			'value'=>'User::itemAlias("AdminStatus",$data->superuser)',
			'filter'=>User::itemAlias("AdminStatus"),
		),
		array(
			'name'=>'status',
			'value'=>'User::itemAlias("UserStatus",$data->status)',
			'filter' => User::itemAlias("UserStatus"),
		),
		array(
            'class' => 'bootstrap.widgets.TbButtonColumn',
            'template' => '{view}{update}{delete}{sendmail}',
            'buttons' => array(
                'view' ,
                'update',
                'delete',
				'sendmail' => array(
					'visible' => 'Yii::app()->helper->checkActive($data->status)',
                    'label' => 'Send Activation email',
                    'icon' => 'fa fa-envelope',
					'options'=>array('style'=>'margin-left: 5px'),
                    'url' => 'Yii::app()->baseUrl ."/index.php/user/registration/activationMail/id/".$data->id."key/".$data->activkey', //A PHP expression for generating the URL of the button.
                )
            ),
            'header' => 'Operations',
            'htmlOptions' => array('width' => 'auto', 'textAlign' => 'center'),
        ),
	),
)); ?>
<script>
	<?php
		if($_GET['activeMail']==1){
			echo 'bootbox.alert("Email activation has been send")';
		}
	?>
</script>